﻿@using Inpinke.Model
@{
    ViewBag.Title = "照片书-Inpinke感受印品的美好";
    IList<Inpinke_Book> bookList = new List<Inpinke_Book>();
    if (Model != null)
    {
        bookList = Model as List<Inpinke_Book>;
    } 
}
<div class="content_wrapper account_wrapper">
    <!--用户菜单-->
    @Html.Partial("_MyMenuPartial")
    <div class="content_wrapper clearfix">
        <div class="mybook_list container">
            @if (Model == null || bookList.Count() <= 0)
            {
                int pic = (new Random()).Next(0, 6);
                <div class="book_item">
                    <div class="book_cover">
                        <a class="" href="javascript:;">
                            <img src="/Content/pagestyle/demo/in_sky_@(pic).jpg" alt="" />
                        </a>
                    </div>
                    <div class="book_details">
                        <h2 class="book_name">
                            印空</h2>
                        <p class="book_sum">
                            你还没有自己的照片书印品，点击快速定制一本吧>>
                        </p>
                    </div>
                </div>
         
            }
            else
            {
                foreach (Inpinke_Book b in bookList)
                {
                <div class="book_item">
                    <div class="product_name_bg">
                        <span class="pd_name">@b.Inpinke_Product.ShortName</span></div>
                    <div class="book_cover">
                        <a class="" href="/show?id=@(b.ID)" target="_blank">
                            <img src="@b.BookCover" alt="" />
                        </a>
                        <div class="done_percent">
                            已完成<span class="percent_num">@{ int percent = b.DonePages * 100 / b.PageCount; percent = percent > 100 ? 100 : percent;}@(percent)%</span>
                        </div>
                    </div>
                    <div class="book_details">
                        <h2 class="book_name">
                            @b.BookName
                            @if (b.ShowStatus == (int)Inpinke.Model.Enum.ShowStatus.Pravice)
                            {
                                <a id="shareBookBtn_@(b.ID)" href="javascript:shareThisBook(@(b.ID))" class="share_book_btn" title="分享">
                                    分享</a>
                            }
                            else
                            {
                                <a id="shareBookBtn_@(b.ID)" href="javascript:shareThisBook(@(b.ID))" class="share_book_btn book_shared" title="取消分享">
                                    取消分享</a>
                            }
                        </h2>
                        <p class="book_sum" title="@(b.BookDesc)">
                            @(System.Text.Encoding.Default.GetByteCount(b.BookDesc) > 170 ? b.BookDesc.Substring(0, 76) + "..." : b.BookDesc)
                        </p>
                        <div class="book_share">
                            <p>
                                <span>规格：@(b.Inpinke_Product.Width + "X" + b.Inpinke_Product.Height)CM</span>&nbsp;&nbsp;<span>页数：@(b.PageCount)</span></p>
                            <p class="share_icon">
                                <span>创建时间：@(b.CreateTime.ToString("yyyy年MM月dd日 HH:mm"))</span> @*分享到：*@
                            </p>
                        </div>
                        <div class="book_info">
                            <p class="book_btn clearfix">
                                @{string editorUrl = "/" + b.Inpinke_Product.ShortName + "/editor?bookid=" + b.ID;}
                                <!--印刷中的书不能编辑--> 
                                <a href="/show?id=@(b.ID)" class="r_btn"  target="_blank">预览</a>
                                @if (b.BookStauts != (int)Inpinke.Model.Enum.BookStatus.Making)
                                {
                                   <a href="@(editorUrl)" class="r_btn" target="_blank">编辑</a>
                                    <a href="/my/delbook?bookid=@(b.ID)" class="r_btn" onclick="return confirm('确定删除当前印品吗？');">
                                        删除</a>
                                }
                                @if (percent > 90)
                                {
                                    <a href="/my/copybook?bookid=@(b.ID)" class="r_btn" title="可拷贝副本进行编辑">复制</a>
                                    <a href="/order/addbook2cart?bookid=@(b.ID)" class="r_btn" target="_blank">下单印书</a>                                    
                                }
                            </p>
                        </div>
                    </div>
                </div>
                }
                <div class="the_pages" style="width: 710px;">
                    @Html.Raw(Html.uiPager4(4))
                </div>
            }
        </div>
        <div class="right_menu_wrapper">
            <div class="menu_box">
                <div class="menu_title">
                    <h2>
                        快速定制印品</h2>
                </div>
                <div class="box_con">
                    <a href="/intime/createintime?prodid=1" target="_blank">
                        <img src="../../Content/pagestyle/images/intime_info.png" alt="" /></a>
                </div>
            </div>
            @Html.Partial("_TopList_Right")
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        var bookCovers = $("div.book_cover");
        bookCovers.bind("mouseover", function () {
            $(this).find("div.done_percent").stop(true, false).animate({ bottom: 0 }, 300);
        })
        bookCovers.bind("mouseout", function () {
            $(this).find("div.done_percent").stop(true, false).animate({ bottom: -40 }, 300);
        })
    })

    function shareThisBook(bookid) {
        var clkObj = $('#shareBookBtn_' + bookid);
        if (clkObj.hasClass('book_shared')) {
            clkObj.removeClass('book_shared');
            clkObj.attr('title', '分享')
        } else {
            clkObj.addClass('book_shared');
            clkObj.attr('title', '取消分享')
        }
        $.ajax({
            url: '/my/ajaxsetbookshowstatus',
            type: 'get',
            dataType: 'json',
            data: { bookid: bookid },
            success: function (r) {
                if (!r.success) {
                    alert(r.msg);
                }
            }
        })

    }
</script>
